import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    proxy: {
      '/api/sql_execute': {  // 代理路径匹配规则，所有以/api/sql_execute开头的请求都会被代理
        target: 'http://localhost:8811',  // 目标服务器地址
        changeOrigin: true,  // 修改请求头中的origin为目标地址
        ws: true,  // 启用WebSocket代理
        rewrite: (path) => path  // 路径重写函数，这里保持原路径不变
      },
      '/api/doris': {
        target: 'http://localhost:8833',
        changeOrigin: true,
        rewrite: (path) => path
      },
      '/api/business-terms': {
        target: 'http://localhost:8085',
        changeOrigin: true,
        rewrite: path => path
      },
      '/api': {
        target: 'http://localhost:8822',
        changeOrigin: true,
        rewrite: (path) => path
      }
    }
  }
})
